package com.guochenglang.www.dao;

import com.guochenglang.www.pojo.User;

import java.sql.SQLException;
import java.util.ArrayList;

/**
 * @author GuoChenglang
 */
public interface UserDao {

    /**
     * 用户查询
     *
     * @param user 查询条件
     * @return 用户列表
     * @throws SQLException           sql异常
     * @throws IllegalAccessException 非法访问异常
     * @throws InstantiationException 实现异常
     * @throws InterruptedException   断点异常
     */
    ArrayList<User> userSelect(User user) throws SQLException, IllegalAccessException, InstantiationException, InterruptedException;

    /**
     * 分页查询用户
     *
     * @param page  页码
     * @param num   每页显示信息
     * @param user  查询条件
     * @param order 排列条件
     * @param mode  升序还是降序
     * @return 用户列表
     * @throws SQLException           sql异常
     * @throws InterruptedException   断点异常
     * @throws IllegalAccessException 非法访问异常
     * @throws InstantiationException 实现异常
     */
    ArrayList<User> userSelectByLimit(int page, int num, User user, String order, String mode) throws SQLException, InterruptedException, IllegalAccessException, InstantiationException;

    /**
     * 添加用户
     *
     * @param user 添加用户的信息
     * @return 添加的得到的主键
     * @throws SQLException           sql异常
     * @throws InterruptedException   断点异常
     * @throws IllegalAccessException 非法访问异常
     */
    int insertUser(User user) throws SQLException, InterruptedException, IllegalAccessException;

    /**
     * 更新用户信息
     *
     * @param set        更新的数据
     * @param conditions 更新的条件
     * @return 更新的行数
     * @throws SQLException           sql异常
     * @throws InterruptedException   断点异常
     * @throws IllegalAccessException 非法访问异常
     */
    int updateUser(User set, User conditions) throws SQLException, InterruptedException, IllegalAccessException;

    /**
     * 删除用户
     *
     * @param conditions 删除条件
     * @return 删除的行数
     * @throws SQLException           sql异常
     * @throws InterruptedException   断点异常
     * @throws IllegalAccessException 非法访问异常
     */
    int deleteUser(User conditions) throws SQLException, InterruptedException, IllegalAccessException;

}
